package com.zhonghan.recharge.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zhonghan.common.bean.Result;
import com.zhonghan.recharge.pojo.ZhCardReceive;
import com.zhonghan.recharge.service.ZhCardReceiveService;
import com.zhonghan.recharge.service.ZhFillCardService;

@RequestMapping("/admin/cardReceive")
@Controller
public class ZhCardReceiveController {

	@Autowired
	private ZhCardReceiveService zhCardReceiveService;
	
	@Autowired
	private ZhFillCardService zhFillCardService;
	
	@RequestMapping("/detailById")
	@ResponseBody
	public Result getSomeReceive(Integer id) {
		
		//通过id，获取信息
		ZhCardReceive cardReceive = zhCardReceiveService.selectZhCardReceiveById(id);
		
		//通过卡段区间 ，找已经消费的，未消费的， 未激活的，
		cardReceive = zhCardReceiveService.selectUsesBySequences(cardReceive);
		Result result = new Result();
		result.setData(cardReceive);
		return result;
	}
	
	/**
	 * 激活卡
	 * @param sequenceBegin 开始卡号
	 * @param sequenceEnd 结束卡号
	 * @return
	 */
	@RequestMapping("/activateCard")
	@ResponseBody
	public String activateCard(String sequenceBegin,String sequenceEnd){
		
		int num = zhFillCardService.updateZhFillCardByStatus(sequenceBegin, sequenceEnd);
		
		return num+"";
	}
}
